package com.jzy.service.impl;

import com.jzy.bean.User;
import com.jzy.mapper.UserMapper;
import com.jzy.service.UserService;
import com.jzy.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ${DESCRIPTION}
 *
 * @author jzy
 * @create 2018-05-11 15:50
 **/
@Service
public class UserServiceImpl implements UserService{

    @Autowired
    UserMapper userMapper;
    @Override
    public void addUser(User user) {
        userMapper.insertUser(user);
    }

    @Override
    public UserVo getUserById(String id) {
        UserVo userVo = userMapper.selectUserById(id);
        if (userVo == null) {
            System.out.println("没有找到该用户");
        }
        return userVo;
    }

    @Override
    public List<UserVo> getUserList(int start, int limit) {

        return userMapper.selectUserList(start * limit, limit);
    }

    @Override
    public void updateUser(UserVo userVo) {
        userMapper.updateUser(userVo);
    }

    @Override
    public int deleteUserById(String id) {

        return userMapper.deleteUser(id);
    }
}
